using System;
using System.Collections.Generic;
namespace IcsSEMCtrl.Com.FieldBus
{
	public class GenericConnectionString : Dictionary<string, object>
	{
		private const char DEFAULT_DELIMETER_01 = ',';
		private const char DEFAULT_DELIMETER_02 = '=';
		private char primeDelimeter = ',';
		private char secondaryDelimeter = '=';
		private string connectionString = string.Empty;
		private char PrimaryDelimeter
		{
			get
			{
				return this.primeDelimeter;
			}
			set
			{
				this.primeDelimeter = value;
			}
		}
		private char SecondaryDelimeter
		{
			get
			{
				return this.secondaryDelimeter;
			}
			set
			{
				this.secondaryDelimeter = value;
			}
		}
		public string ConnectionString
		{
			get
			{
				return this.connectionString;
			}
		}
		public short this[string key, short defaultValue]
		{
			get
			{
				return base.ContainsKey(key) ? Convert.ToInt16(base[key]) : defaultValue;
			}
		}
		public int this[string key, int defaultValue]
		{
			get
			{
				return base.ContainsKey(key) ? Convert.ToInt32(base[key]) : defaultValue;
			}
		}
		public int this[string key, int defaultValue, int iBase]
		{
			get
			{
				return base.ContainsKey(key) ? Convert.ToInt32(base[key].ToString(), iBase) : defaultValue;
			}
		}
		public string this[string key, string defaultValue]
		{
			get
			{
				return base.ContainsKey(key) ? base[key].ToString() : defaultValue;
			}
		}
		public DateTime this[string key, DateTime defaultValue]
		{
			get
			{
				return base.ContainsKey(key) ? Convert.ToDateTime(base[key]) : defaultValue;
			}
		}
		public void Parse(string strConnectionString)
		{
			this.connectionString = strConnectionString;
			string[] array = strConnectionString.Split(new char[]
			{
				this.primeDelimeter
			});
			base.Clear();
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text = array2[i];
				string[] array3 = text.Split(new char[]
				{
					this.secondaryDelimeter
				});
				if (array3.Length == 2)
				{
					string text2 = array3[0].Trim().ToUpper();
					string strValue = array3[1].Trim();
					base.Add(text2, this.GetValue(text2, strValue));
				}
			}
		}
		protected virtual object GetValue(string strName, string strValue)
		{
			return strValue;
		}
	}
}
